/**
 * My brain is better than everybody's
 */

package com.duan.ssm.controller;

import com.duan.ssm.entity.Department;
import com.duan.ssm.service.impl.DeptServiceImpl;
import com.duan.ssm.service.intf.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class MyController {

    @Autowired
    private DeptService deptService;

    @RequestMapping("add.do")
    public String save(Department department){

        deptService.save(department);

        return "index";
    }

    @RequestMapping("delete.do")
    public String delete(Integer id){
        int delete = deptService.delete(id);
        System.out.println("delete = " + delete);
        return "index";
    }

    @RequestMapping("select.do")
    public String select(){
        List<Department> select = deptService.select();
        select.forEach(System.out::println);

        return "index";
    }



}
